Ensure that the path is always set
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 5 Dec 2017 11:07:46 +0000 (11:07 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Tue, 5 Dec 2017 11:07:46 +0000 (11:07 +0000)
We are using `path` unconditionally, but it can be conditionally filled.
To avoid inconsistent internal state, and a compiler warning, let's
assert that the variable is always set.

gdk/gdkcontentserializer.c

index e033272ac5f40aae762728b55fc56ad8541e467e..1a6add92ec5f9f49cb75052989c85a0d6f4e2fc5 100644 (file)
@@ -615,7 +615,7 @@ static void
 file_text_serializer (GdkContentSerializer *serializer)
 {
   const GValue *value;
-  char *path;
+  char *path = NULL;
 
   value = gdk_content_serializer_get_value (serializer);
 
@@ -651,6 +651,8 @@ file_text_serializer (GdkContentSerializer *serializer)
       path = g_string_free (str, FALSE);
     }
 
+  g_assert (path != NULL);
+
   g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
                                    path,
                                    strlen (path),